﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using CreditAgricole.Framework;

namespace CreditAgricole.TestConsole
{
    class Program
    {
        const string SITE = @"http://shdevlux002/sites/serge";
        const string WEB = @"test";

        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            
            using (SPSite site = new SPSite(SITE))
            {
                using (SPWeb web = site.OpenWeb(WEB))
                {
                    Console.WriteLine("Website open");
                    SPList list = web.Lists["TestList"];

                    SPListItemCollection items = list.Items;
                    foreach (SPListItem item in items)
                    {
                        Console.WriteLine(item[SPBuiltInFieldId.Title]);
                        SPFieldUserValueCollection uvc = SPHelper.GetSPUsers(item, "MyCustomUser");

                        foreach (SPFieldUserValue u in uvc)
                        {
                            Console.WriteLine("\t{0}", u.User.Name);
                        }
                    }
                    Console.WriteLine("\r\n<Press any key to exit>");
                    Console.ReadKey(true);
                }
            }
        }
    }
}
